home *** CD-ROM | disk | FTP | other *** search
/ SGI Performance Co-Pilot 1.3 / SGI Performance Co-Pilot 1.3.iso / dist / pcp.idb / usr / pcp / lib / pmdaproc.sh.z / pmdaproc.sh
Text File  |  1997-04-03  |  18KB  |  822 lines

  1. # Common sh(1) procedures to be used in the Performance Co-Pilot
  2. # PMDA Install and Remove scripts
  3. #
  4. # $Id: pmdaproc.sh,v 2.5 1997/04/02 18:05:32 kenmcd Exp $
  5. #
  6. # Copyright 1995, Silicon Graphics, Inc.
  7. # ALL RIGHTS RESERVED
  8. # UNPUBLISHED -- Rights reserved under the copyright laws of the United
  9. # States.   Use of a copyright notice is precautionary only and does not
  10. # imply publication or disclosure.
  11. # U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
  12. # Use, duplication or disclosure by the Government is subject to restrictions
  13. # as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
  14. # in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
  15. # in similar or successor clauses in the FAR, or the DOD or NASA FAR
  16. # Supplement.  Contractor/manufacturer is Silicon Graphics, Inc.,
  17. # 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
  18. # THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
  19. # INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
  20. # DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
  21. # PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
  22. # GRAPHICS, INC.
  23.  
  24. # some useful common variables for Install/Remove scripts
  25. #
  26. # writeable root of PMNS
  27. NAMESPACE=${PMNS_DEFAULT-/var/pcp/pmns/root}
  28. PMNSROOT=`basename $NAMESPACE`
  29.  
  30. # put you PMNS files here
  31. PMNSDIR=`dirname $NAMESPACE`
  32.  
  33. # install your DSO PMDAs here
  34. DSOPMDADIR=/var/pcp/lib
  35.  
  36. # Install control variables
  37. #    Can install as DSO?
  38. dso_opt=false
  39. #    Can install as daemon?
  40. daemon_opt=true
  41. #    If daemon, pipe?
  42. pipe_opt=true
  43. #    If daemon, socket?  and default for Internet sockets?
  44. socket_opt=false
  45. socket_inet_def=''
  46. #    IPC Protocol for daemon (binary or text)
  47. ipc_prot=binary
  48. #    Delay after install before checking (sec)
  49. check_delay=3
  50. #    Additional command line args to go in /etc/pmcd.conf
  51. args=""
  52. #    Source for the pmns
  53. pmns_source=pmns
  54. #    Source for the helptext
  55. help_source=help
  56. #    Assume no valid licenses
  57. LICENSE_PCP=false
  58. LICENSE_WEBMETER=false
  59.  
  60. # Other variables and constants
  61. #
  62. prog=`basename $0`
  63. here=`pwd`
  64. tmp=/var/tmp/$$
  65. do_pmda=true
  66. do_check=true
  67.  
  68. trap "rm -f $tmp $tmp.*; exit" 0 1 2 3 15
  69.  
  70. # Parse command line args
  71. #
  72. while [ $# -gt 0 ]
  73. do
  74.     case $1
  75.     in
  76.     -N)    # name space only
  77.         do_pmda=false
  78.         ;;
  79.  
  80.     -n)    # alternate name space
  81.         if [ $# -lt 2 ]
  82.         then
  83.         echo "$prog: -n requires a name space file option"
  84.         exit 1
  85.         fi
  86.         NAMESPACE=$2
  87.         PMNSROOT=`basename $NAMESPACE`
  88.         PMNSDIR=`dirname $NAMESPACE`
  89.         shift
  90.         ;;
  91.  
  92.     -Q)    # skip check for metrics going away
  93.         do_check=false
  94.         ;;
  95.  
  96.     -R)    # $ROOT
  97.         if [ "$prog" = "Remove" ]
  98.         then
  99.         echo "Usage: $prog [-N] [-n namespace] [-Q]"
  100.         exit 1
  101.         fi
  102.         if [ $# -lt 2 ]
  103.         then
  104.         echo "$prog: -R requires a directory option"
  105.         exit 1
  106.         fi
  107.         root=$2
  108.         shift
  109.         ;;
  110.  
  111.     *)
  112.         if [ "$prog" = "Install" ]
  113.         then
  114.         echo "Usage: $prog [-N] [-n namespace] [-Q] [-R rootdir]"
  115.         else
  116.         echo "Usage: $prog [-N] [-n namespace] [-Q]"
  117.         fi
  118.         exit 1
  119.         ;;
  120.     esac
  121.     shift
  122. done
  123.  
  124. # pmda_cull name domain
  125. #
  126. pmda_cull()
  127. {
  128.     # context and integrity checks
  129.     #
  130.     [ ! -f /etc/pmcd.conf ] && return
  131.     if [ ! -w /etc/pmcd.conf ]
  132.     then
  133.     echo "pmda_cull: \"/etc/pmcd.conf\" is not writeable"
  134.     exit 1
  135.     fi
  136.     if [ $# -ne 2 ]
  137.     then
  138.     echo "internal botch: pmda_cull() called with $# (instead of 2) arguments"
  139.     exit 1
  140.     fi
  141.  
  142.     # remove matching entry from /etc/pmcd.conf if present
  143.     #
  144.     nawk </etc/pmcd.conf >/tmp/$$.pmcd.conf '
  145. BEGIN                    { status = 0 }
  146. $1 == "'"$1"'" && $2 == "'"$2"'"     { status = 1; next }
  147.                     { print }
  148. END                    { exit status }'
  149.     if [ $? -eq 0 ]
  150.     then
  151.     # no match
  152.     rm -f /tmp/$$.pmcd.conf
  153.     return
  154.     fi
  155.     
  156.     # log change to /var/adm/pcplog/NOTICES
  157.     #
  158.     /usr/pcp/bin/pmpost "pmda_cull: from /etc/pmcd.conf: $1 $2"
  159.  
  160.     # install updated /etc/pmcd.conf
  161.     #
  162.     cp /tmp/$$.pmcd.conf /etc/pmcd.conf
  163.     rm -f /tmp/$$.pmcd.conf
  164.  
  165.     # signal pmcd if it is running
  166.     #
  167.     if pminfo -v pmcd.version >/dev/null 2>&1
  168.     then
  169.     killall -HUP pmcd
  170.     # wait for pmcd to respond ...
  171.     # would be better to have a pmcd generation number, but we do not
  172.     # have that
  173.     sleep 10
  174.     fi
  175. }
  176.  
  177. # pmda_add "entry for /etc/pmcd.conf"
  178. #
  179. pmda_add()
  180. {
  181.     # context and integrity checks
  182.     #
  183.     if [ ! -w /etc/pmcd.conf ]
  184.     then
  185.     echo "pmda_add: \"/etc/pmcd.conf\" is not writeable"
  186.     exit 1
  187.     fi
  188.     if [ $# -ne 1 ]
  189.     then
  190.     echo "internal botch: pmda_add() called with $# (instead of 1) arguments"
  191.     exit 1
  192.     fi
  193.  
  194.     myname=`echo $1 | nawk '{print $1}'`
  195.     mydomain=`echo $1 | nawk '{print $2}'`
  196.     # add entry to /etc/pmcd.conf
  197.     #
  198.     echo >/tmp/$$.pmcd.access
  199.     nawk </etc/pmcd.conf '
  200. NF==0                    { next }
  201. /^[      ]*\[[   ]*access[       ]*\]/    { state = 2 }
  202. state == 2                { print >"'/tmp/$$.pmcd.access'"; next }
  203. $1=="'$myname'" && $2=="'$mydomain'"    { next }
  204.                     { print >"'/tmp/$$.pmcd.body'"; next }'
  205.     ( cat /tmp/$$.pmcd.body \
  206.       ; echo "$1" \
  207.       ; cat /tmp/$$.pmcd.access \
  208.     ) >/etc/pmcd.conf
  209.     rm -f /tmp/$$.pmcd.access /tmp/$$.pmcd.body
  210.  
  211.     # log change to /var/adm/pcplog/NOTICES
  212.     #
  213.     /usr/pcp/bin/pmpost "pmda_add: to /etc/pmcd.conf: $1"
  214.  
  215.     # signal pmcd if it is running, else start it
  216.     #
  217.     if pminfo -v pmcd.version >/dev/null 2>&1
  218.     then
  219.     killall -HUP pmcd
  220.     # wait for pmcd to respond ...
  221.     # would be better to have a pmcd generation number, but we do not
  222.     # have that
  223.     sleep 10
  224.     else
  225.     log=${PCP_LOGDIR-/var/adm/pcplog}/pmcd.log
  226.     rm -f $log
  227.     /etc/init.d/pcp start
  228.     for i in 1 2 3 4 5
  229.     do
  230.         sleep 1
  231.         pminfo -v pmcd.version >/dev/null 2>&1 && return
  232.     done
  233.     # some problem starting pmcd
  234.     #
  235.     echo "Fatal error: unable to start pmcd ..."
  236.     if [ -f $log ]
  237.     then
  238.         echo "Log file ..."
  239.         cat $log
  240.     else
  241.         echo "No log file ($log)!!"
  242.     fi
  243.     fi
  244. }
  245.  
  246. # expect -R root or $ROOT not set in environment
  247. #
  248. check_root()
  249. {
  250.     if [ "X$root" != X ]
  251.     then
  252.     ROOT="$root"
  253.     export ROOT
  254.     else
  255.     if [ "X$ROOT" != X -a "X$ROOT" != X/ ]
  256.     then
  257.         echo "Install: \$ROOT was set to \"$ROOT\""
  258.         echo "          Use -R rootdir to install somewhere other than /"
  259.         exit 1
  260.     fi
  261.     fi
  262. }
  263.  
  264. # should be able to extract default domain from domain.h
  265. #
  266. check_domain()
  267. {
  268.     if [ -f domain.h ]
  269.     then
  270.     # $domain is for backwards compatibility, modern PMDAs
  271.     # have something like
  272.     #    #define FOO 123
  273.     #
  274.     domain=''
  275.     eval `nawk <domain.h '
  276. /^#define/ && $3 ~ /^[0-9][0-9]*$/    { print $2 "=" $3
  277.                       if (seen == 0) {
  278.                         print "domain=" $3
  279.                         print "SYMDOM=" $2
  280.                         seen = 1
  281.                       }
  282.                     }'`
  283.     if [ "X$domain" = X ]
  284.     then
  285.         echo "Install: cannot determine the Performance Metrics Domain from ./domain.h"
  286.         exit 1
  287.     fi
  288.     else
  289.     echo "Install: cannot find ./domain.h to determine the Performance Metrics Domain"
  290.     exit 1
  291.     fi
  292. }
  293.  
  294. # choose correct PMDA installation mode
  295. #
  296. # make sure we are installing in the correct style of configuration
  297. #
  298. choose_mode()
  299. {
  300.     def=m
  301.     $do_pmda && def=b
  302.     echo \
  303. 'You will need to choose an appropriate configuration for installation of
  304. the "'$iam'" Performance Metrics Domain Agent (PMDA).
  305.  
  306.   collector    collect performance statistics on this system
  307.   monitor    allow this system to monitor local and/or remote systems
  308.   both        collector and monitor configuration for this system
  309. '
  310.     while true
  311.     do
  312.     echo 'Please enter c(ollector) or m(onitor) or b(oth) ['$def'] \c'
  313.     read ans
  314.     case "$ans"
  315.     in
  316.         "")    break
  317.             ;;
  318.         c|collector|b|both)
  319.             do_pmda=true
  320.             break
  321.             ;;
  322.         m|monitor)
  323.             do_pmda=false
  324.             break
  325.             ;;
  326.         *)    echo "Sorry, that is not acceptable response ..."
  327.             ;;
  328.     esac
  329.     done
  330.     echo
  331. }
  332.  
  333. # choose an IPC method
  334. #
  335. choose_ipc()
  336. {
  337.     _dir=${1-/usr/pcp/lib}
  338.     ipc_type=''
  339.     $pipe_opt && ipc_type=pipe
  340.     $socket_opt && ipc_type=socket
  341.     $pipe_opt && $socket_opt && ipc_type=''
  342.     if [ -z "$ipc_type" ]
  343.     then
  344.     while true
  345.     do
  346.         echo "PMCD should communicate with the $iam daemon via a pipe or a socket? [pipe] \c"
  347.         read ipc_type
  348.         if  [ "X$ipc_type" = Xpipe -o "X$ipc_type" = X ]
  349.         then
  350.         ipc_type=pipe
  351.         break
  352.         elif [ "X$ipc_type" = Xsocket ]
  353.         then
  354.         break
  355.         else
  356.         echo "Must choose one of \"pipe\" or \"socket\", please try again"
  357.         fi
  358.     done
  359.     fi
  360.  
  361.     if [ $ipc_type = pipe ]
  362.     then
  363.     type="pipe    $ipc_prot         $_dir/$pmda_name"
  364.     else
  365.     echo "Use Internet or Unix domain sockets? [Internet] \c"
  366.     read ans
  367.     if [ "X$ans" = XInternet -o "X$ans" = X ]
  368.     then
  369.         echo "Internet port number or service name? [$socket_inet_def] \c"
  370.         read port
  371.         [ "X$port" = X ] && port=$socket_inet_def
  372.         case $port
  373.         in
  374.         [0-9]*)
  375.             ;;
  376.         *)
  377.             if grep "^$port[     ]*[0-9]*/tcp" /etc/services >/dev/null 2>&1
  378.             then
  379.                 :
  380.             else
  381.                 echo "Warning: there is no tcp service for \"$port\" in /etc/services!"
  382.             fi
  383.             ;;
  384.         esac
  385.         type="socket    inet $port    $_dir/$pmda_name"
  386.         args="-i $port $args"
  387.         break
  388.     elif [ "X$ans" = XUnix ]
  389.     then
  390.         echo "Unix FIFO name? \c"
  391.         read fifo
  392.         if [ "X$fifo" = X ]
  393.         then
  394.         echo "Must provide a name, please try again"
  395.         else
  396.         type="socket    unix $fifo    $_dir/$pmda_name"
  397.         args="-u $fifo $args"
  398.         break
  399.         fi
  400.     else
  401.         echo "Must choose one of \"Unix\" or \"Internet\", please try again"
  402.     fi
  403.     fi
  404. }
  405.  
  406. # determine license capabilities you have, report and exit if
  407. # no licenses are valid
  408. #
  409. # Note.  if someone fakes out /usr/pcp/bin/pmbrand, this test will produce
  410. #     the wrong result, but other things down stream will not work
  411. #
  412. _check_license()
  413. {
  414.     LICENSE_PCP=false
  415.     LICENSE_WEBMETER=false
  416.     [ ! -x /usr/pcp/bin/pmbrand ] && return
  417.     rm -f /tmp/.$$.check
  418.     /usr/pcp/bin/pmbrand -l >/tmp/.$$.check 2>&1
  419.     fgrep -s 'PCP' </tmp/.$$.check && LICENSE_PCP=true
  420.     fgrep -s 'WEBPERF
  421. WebMeter' </tmp/.$$.check && LICENSE_WEBMETER=true
  422.     rm -f /tmp/.$$.check
  423.  
  424.     if [ $LICENSE_PCP = false -a $LICENSE_WEBMETER = false ]
  425.     then
  426.     echo
  427.     echo \
  428. 'There are no valid Performance Co-Pilot licenses installed on this host.
  429. Please install a valid Collector, Monitor or WebMeter license before
  430. attempting to install this PMDA again.'
  431.       echo
  432.     exit 1
  433.     fi
  434.  
  435.     if [ $LICENSE_PCP = false -a $LICENSE_WEBMETER = true ]
  436.     then
  437.         NAMESPACE=/var/pcp/pmns/root_web
  438.     PMNSROOT=`basename $NAMESPACE`
  439.     PMNSDIR=`dirname $NAMESPACE`
  440.         if [ ! -r $NAMESPACE ]
  441.         then
  442.         echo
  443.         echo \
  444. 'The WebMeter license requires the WebMeter product, and hence the file
  445. $NAMESPACE, to be installed.'
  446.         echo
  447.         exit 1
  448.         fi
  449.     fi
  450. }
  451.  
  452. # Function to filter pminfo output
  453. #
  454. _filter()
  455. {
  456.     awk '
  457. NF==0        { next }
  458. / value /    { value++; next }
  459. /^'$1'/        { metric++
  460.           if ($0 !~ /:/) next
  461.         }
  462.         { warn++ }
  463. END        { if (warn) printf "%d warnings, ",warn
  464.           printf "%d metrics and %d values\n",metric,value
  465.         }'
  466. }
  467.  
  468. _setup()
  469. {
  470.     # Set $domain and $SYMDOM from domain.h
  471.     #
  472.     check_domain
  473.  
  474.     case $prog
  475.     in
  476.     *Install*)
  477.         # Check that $ROOT is not set, we have a default domain value and
  478.         # choose the installation mode (collector, monitor or both)
  479.         #
  480.         check_root
  481.         choose_mode
  482.         ;;
  483.     esac
  484.  
  485.     # some more configuration controls
  486.     pmns_name=${iam}
  487.     pmda_name=pmda${iam}
  488.     dso_name=pmda_${iam}.so
  489.     dso_entry=${iam}_init
  490. }
  491.  
  492. # Configurable PMDA installation
  493. #
  494. # before calling _install,
  495. # 1. set $iam
  496. # 2. set one or both of $dso_opt or $daemon_opt true (optional, $daemon_opt
  497. #    is true by default)
  498. # 3. if $dso_opt set one or both of $pipe_opt or $socket_opt true (optional,
  499. #    $pipe_opt is true by default)
  500. # 4. if $socket_opt and there is an default Internet socket, set
  501. #    $socket_inet_def
  502.  
  503. _install()
  504. {
  505.     if [ -z "$iam" ]
  506.     then
  507.     echo 'Botch: must define $iam before calling _install_preamble()'
  508.     exit 1
  509.     fi
  510.  
  511.     if $do_pmda
  512.     then
  513.     if $dso_opt || $daemon_opt
  514.     then
  515.         :
  516.     else
  517.         echo 'Botch: must set at least one of $dso_opt or $daemon_opt to "true"'
  518.         exit 1
  519.     fi
  520.     if $daemon_opt
  521.     then
  522.         if $pipe_opt || $socket_opt
  523.         then
  524.         :
  525.         else
  526.         echo 'Botch: must set at least one of $pipe_opt or $socket_opt to "true"'
  527.         exit 1
  528.         fi
  529.     fi
  530.     fi
  531.  
  532.     # check that we have a valid license: for WebMeter, skip the PMNS changes
  533.     #
  534.     _check_license
  535.  
  536.     if $LICENSE_PCP
  537.     then
  538.         echo "Updating the Performance Metrics Name Space (PMNS) ..."
  539.         if pminfo -n $NAMESPACE $pmns_name >/dev/null 2>&1
  540.         then
  541.         cd $PMNSDIR
  542.         if /usr/pcp/bin/pmnsdel -n $PMNSROOT $pmns_name >$tmp 2>&1
  543.         then
  544.             :
  545.          else
  546.             if grep 'Non-terminal "'"$pmns_name"'" not found' $tmp >/dev/null
  547.             then
  548.             :
  549.         elif grep 'Error: metricpath "'"$pmns_name"'" not defined' $tmp >/dev/null
  550.         then
  551.             :
  552.             else
  553.             echo "$prog: failed to delete \"$pmns_name\" from the PMNS"
  554.             cat $tmp
  555.             exit 1
  556.             fi
  557.         fi
  558.         cd $here
  559.         fi
  560.     fi
  561.  
  562.     if $LICENSE_PCP
  563.     then
  564.         # Install the namespace
  565.         #
  566.  
  567.     # Put the default domain number into the namespace file
  568.     #
  569.     sed -e "s/$SYMDOM/$domain/" <$pmns_source >$PMNSDIR/$pmns_name
  570.  
  571.         cd $PMNSDIR
  572.         if /usr/pcp/bin/pmnsadd -n $PMNSROOT $pmns_name
  573.        then
  574.         :
  575.         else
  576.         echo "$prog: failed to add the PMNS entries for \"$pmns_name\" ..."
  577.         echo
  578.         ls -l
  579.         exit 1
  580.         fi
  581.         cd $here
  582.     elif $LICENSE_WEBMETER
  583.     then
  584.     if pminfo $pmns_name >$tmp.chk 2>&1
  585.     then
  586.         :
  587.     else
  588.         cat $tmp.chk
  589.         echo \
  590. 'This system has a WebMeter license which prohibits changes to the PMNS,
  591. and the required "'$pmns_name'" metrics are not currently in the PMNS.'
  592.         echo
  593.         if $do_pmda
  594.         then
  595.         echo \
  596. 'To install the "'$iam'" PMNS and PMDA on this system, you must
  597. upgrade to a full PCP Collector license'
  598.         else
  599.         echo \
  600. 'To install the "'$iam'" PMNS on this system, you must upgrade to a
  601. full PCP Monitor license'
  602.         fi
  603.         echo
  604.         exit 1
  605.     fi
  606.     else
  607.     echo "$prog: Warning: no valid PCP license"
  608.     echo "PMNS not updated, and this may cause the installation to fail."
  609.     echo
  610.     fi
  611.     
  612.     if [ -d /var/pcp/config/pmchart ]
  613.     then
  614.     echo "Installing pmchart view(s) ..."
  615.     for i in *.pmchart
  616.     do
  617.         if [ "$i" != "*.pmchart" ]
  618.         then
  619.         dest=/var/pcp/config/pmchart/`basename $i .pmchart`
  620.         rm -f $dest
  621.         cp $i $dest
  622.         fi
  623.     done
  624.     else
  625.     echo "Skip installing pmchart view(s) ... no \"/var/pcp/config/pmchart\" directory"
  626.     fi
  627.  
  628.     # Prompt for command line arguments to the PMDA
  629.     #
  630.     if $do_pmda
  631.     then
  632.     # Select an IPC method for communication between PMCD and PMDA
  633.     #
  634.     pmda_type=''
  635.     $dso_opt && pmda_type=dso
  636.     $daemon_opt && pmda_type=daemon
  637.     $dso_opt && $daemon_opt && pmda_type=''
  638.     if [ -z "$pmda_type" ]
  639.         then
  640.         while true
  641.         do
  642.         echo "Install $iam as a daemon or dso agent? [daemon] \c"
  643.         read pmda_type
  644.         if [ "X$pmda_type" = Xdaemon -o "X$pmda_type" = X ]
  645.         then
  646.             pmda_type=daemon
  647.             break
  648.         elif [ "X$pmda_type" = Xdso ]
  649.         then
  650.             break
  651.         else
  652.             echo "Must choose one of \"daemon\" or \"dso\", please try again"
  653.         fi
  654.         done
  655.     fi
  656.     if [ "$pmda_type" = daemon ]
  657.     then
  658.         choose_ipc /var/pcp/pmdas/$iam
  659.         args="-d $domain $args"
  660.     else
  661.         type="dso    $dso_entry    $dso_name"
  662.         args=""
  663.     fi
  664.  
  665.     # Fix domain in help for instance domains (if any)
  666.     #
  667.     if [ -f $help_source ]
  668.     then
  669.         sed -e "/^@ $SYMDOM/s/$SYMDOM/$domain/" <$help_source \
  670.         | /usr/pcp/bin/newhelp -o $help_source
  671.     fi
  672.  
  673.     # Terminate old PMDA
  674.     #
  675.     echo "Terminate PMDA if already installed ..."
  676.     pmda_cull $iam $domain
  677.  
  678.     # Install binaries
  679.     #
  680.     echo "Installing files ..."
  681.     if [ "$pmda_type" = dso ]
  682.     then
  683.         # stolen from /etc/init.d/pcp _reboot_setup()
  684.         # choice depend on the binary format of the booted kernel
  685.         #
  686.         BINFMT=""
  687.         if [ -f /unix ]
  688.         then
  689.         case "`file /unix`"
  690.         in
  691.             *ELF\ 64-bit\ *)
  692.             BINFMT=mips_64
  693.             ;;
  694.             *MIPSEB\ *COFF\ *|*ELF\ 32-bit\ *)
  695.             BINFMT=mips_o32
  696.             ;;
  697.             *ELF\ New\ 32-bit\ *)
  698.             BINFMT=mips_n32
  699.         esac
  700.         fi
  701.         if [ "X$BINFMT" = X ]
  702.         then
  703.         echo "$prog: Cannot determine kernel binary format from /unix"
  704.         echo "$prog: Warning: defaulting to MIPS o32-bit binary format"
  705.         BINFMT=mips_o32
  706.         fi
  707.         STYLE="$BINFMT"
  708.     else
  709.         STYLE=""
  710.     fi
  711.  
  712.     if make STYLE="$STYLE" install
  713.     then
  714.         :
  715.     else
  716.         echo "$prog: Arrgh, \"make install\" failed!"
  717.         exit 1
  718.     fi
  719.  
  720.     # Add PMDA to pmcd's configuration file
  721.     #
  722.     echo "Updating the PMCD control file, and notifying PMCD ..."
  723.     pmda_add "$iam    $domain    $type $args"
  724.  
  725.     # Check that the agent is running OK
  726.     #
  727.     if $do_check
  728.     then
  729.         [ "$check_delay" -gt 5 ] && echo "Wait $check_delay seconds for the $iam agent to initialize ..."
  730.         sleep $check_delay
  731.         echo "Check $iam metrics have appeared ... \c"
  732.         pminfo -n $NAMESPACE -f $pmns_name | _filter $pmns_name
  733.     fi
  734.     else
  735.     echo "Skipping PMDA install and PMCD re-configuration"
  736.     fi
  737. }
  738.  
  739. _remove()
  740. {
  741.  
  742.     # check that we have a valid license: for WebMeter, skip the PMNS changes
  743.     #
  744.     _check_license
  745.  
  746.     if $LICENSE_PCP
  747.     then
  748.         # Update the namespace
  749.         #
  750.  
  751.     echo "Culling the Performance Metrics Name Space ..."
  752.     cd $PMNSDIR
  753.  
  754.     echo "$iam ... \c"
  755.     if /usr/pcp/bin/pmnsdel -n $PMNSROOT $pmns_name >$tmp 2>&1
  756.     then
  757.         rm -f $PMNSDIR/$pmns_name
  758.         echo "done"
  759.     else
  760.         if grep 'Non-terminal "'"$pmns_name"'" not found' $tmp >/dev/null
  761.         then
  762.         echo "not found in Name Space, this is OK"
  763.         elif grep 'Error: metricpath "'"$pmns_name"'" not defined' $tmp >/dev/null
  764.         then
  765.         echo "not found in Name Space, this is OK"
  766.         else
  767.         echo "error"
  768.         cat $tmp
  769.         exit
  770.         fi
  771.     fi
  772.     elif $LICENSE_WEBMETER
  773.     then
  774.     :
  775.     else
  776.     echo "$prog: Warning: no valid PCP license"
  777.     echo "PMNS not updated, and this may cause the removal to fail."
  778.     echo
  779.     fi
  780.  
  781.     # Remove the PMDA and help files
  782.     #
  783.     cd $here
  784.  
  785.     if $do_pmda
  786.     then
  787.     echo "Updating the PMCD control file, and notifying PMCD ..."
  788.     pmda_cull $iam $domain
  789.  
  790.     echo "Removing files ..."
  791.     make clobber >/dev/null
  792.     for i in *.pmchart
  793.     do
  794.         if [ "$i" != "*.pmchart" ]
  795.         then
  796.         dest=/var/pcp/config/pmchart/`basename $i .pmchart`
  797.         rm -f $dest
  798.         fi
  799.     done
  800.  
  801.     if $LICENSE_PCP
  802.     then
  803.         if $do_check
  804.         then
  805.         echo "Check $iam metrics have gone away ... \c"
  806.         if pminfo -n $NAMESPACE -f $pmns_name >$tmp 2>&1
  807.         then
  808.             echo "Arrgh, something has gone wrong!"
  809.             cat $tmp
  810.         else
  811.             echo "OK"
  812.         fi
  813.         fi
  814.     fi
  815.     else
  816.     echo "Skipping PMDA removal and PMCD re-configuration"
  817.     fi
  818. }
  819.